package com.yupi.springbootinit.manager;

import com.yupi.springbootinit.common.ErrorCode;
import com.yupi.springbootinit.exception.BusinessException;
import com.yupi.yucongming.dev.client.YuCongMingClient;
import com.yupi.yucongming.dev.common.BaseResponse;
import com.yupi.yucongming.dev.model.DevChatRequest;
import com.yupi.yucongming.dev.model.DevChatResponse;
import org.springframework.stereotype.Component;


import javax.annotation.Resource;

/**
 * manager 提供的是ai 通用的
 */
@Component
public class AiManager {


    @Resource
    private YuCongMingClient client;

    public String doChat(String message){
        DevChatRequest devChatRequest = new DevChatRequest();
        devChatRequest.setModelId(1789928365347250178L);
        devChatRequest.setMessage(message);


        BaseResponse<DevChatResponse> response = client.doChat(devChatRequest);
        if (response == null) {
            throw new BusinessException(ErrorCode.PARAMS_ERROR,"ai 响应错误");
        }
//        System.out.println(response.getData());
        return response.getData().getContent();

    }
}
